<html>
<head><meta charset="utf-8"><title>rust-analyzer#930 · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html">rust-analyzer#930</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159986828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986828">(Mar 05 2019 at 08:59)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> What does the <code>recovery_set</code> do ? Match arm has </p>
<div class="codehilite"><pre><span></span><span class="w">    </span><span class="n">p</span><span class="p">.</span><span class="n">eat</span><span class="p">(</span><span class="n">PIPE</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">patterns</span>::<span class="n">pattern_r</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">TokenSet</span>::<span class="n">empty</span><span class="p">());</span><span class="w"></span>
</pre></div>



<a name="159986894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986894">(Mar 05 2019 at 09:00)</a>:</h4>
<p>They control behavior when an unexpcted token is enountered</p>



<a name="159986911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986911">(Mar 05 2019 at 09:00)</a>:</h4>
<p>for <code>struct Foo bar</code>, you'll want to consume the <code>bar</code> token as an erroneous token</p>



<a name="159986946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986946">(Mar 05 2019 at 09:01)</a>:</h4>
<p>for <code>struct Foo fn</code>, you want to <strong>not</strong> consume <code>fn</code>, such that it can be parsed as a part of the folowing function for code liks this:</p>
<div class="codehilite"><pre><span></span>struct Foo

fn bar() {}
</pre></div>



<a name="159986954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986954">(Mar 05 2019 at 09:01)</a>:</h4>
<p>recovery_set is the set of tokens you can't consume</p>



<a name="159986963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159986963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159986963">(Mar 05 2019 at 09:01)</a>:</h4>
<p>using the grammar language, it is something aking to a <code>FOLLOW</code> set</p>



<a name="159987020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987020">(Mar 05 2019 at 09:02)</a>:</h4>
<p>Aha! Thanks, so I think when it comes to piped patterns both conditionals and matches can parse the first piped pattern with empty recovery set ?</p>



<a name="159987174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987174">(Mar 05 2019 at 09:05)</a>:</h4>
<p>e.g. </p>
<div class="codehilite"><pre><span></span><span class="w">    </span><span class="n">p</span><span class="p">.</span><span class="n">eat</span><span class="p">(</span><span class="n">PIPE</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">pattern_r</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">TokenSet</span>::<span class="n">empty</span><span class="p">());</span><span class="w"></span>
<span class="w">   </span><span class="c1">// loop here for rest of the piped patterns</span>
</pre></div>



<a name="159987185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987185">(Mar 05 2019 at 09:05)</a>:</h4>
<p>Yeah, I think something like this should work</p>



<a name="159987202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987202">(Mar 05 2019 at 09:05)</a>:</h4>
<p>though, we probably might want to be more careful in lets</p>



<a name="159987209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987209">(Mar 05 2019 at 09:05)</a>:</h4>
<p>for <code>match</code>, we have <code>{}</code>, so error recovery is not imiportant</p>



<a name="159987264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987264">(Mar 05 2019 at 09:06)</a>:</h4>
<p>for let, I expect the following should parse resonably:</p>
<div class="codehilite"><pre><span></span>let

let foo = 92;
</pre></div>


<p>That is, the second let should be recognized as such</p>



<a name="159987266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987266">(Mar 05 2019 at 09:06)</a>:</h4>
<p>I think we have a test for this</p>



<a name="159987368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987368">(Mar 05 2019 at 09:08)</a>:</h4>
<p>Yeah, 0019_let_recover</p>



<a name="159987423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987423">(Mar 05 2019 at 09:09)</a>:</h4>
<p>So, I think the recovery set should be a parameter of the function</p>



<a name="159987437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987437">(Mar 05 2019 at 09:09)</a>:</h4>
<p>we set it to smth for let, and leave it empy for match</p>



<a name="159987924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987924">(Mar 05 2019 at 09:19)</a>:</h4>
<p>hmm, I wonder what would be proper value for the conditional let pattern recovery set, it only occurs when you have <code>if</code> or <code>while</code> followed by <code>let</code></p>



<a name="159987940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer%23930/near/159987940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/rust-analyzer.23930.html#159987940">(Mar 05 2019 at 09:19)</a>:</h4>
<p>the same as for usual <code>let</code> I suppose</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>